<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@include file="../head.jsp"%>
<html>
<head>
<script type="text/javascript">
(function(){
    Ext.onReady(function(){

        var result = <s:property value="#request.result" escape="false"/>;

        var data = [];
        var s = result.sizeDesc.split(';');
        var total = [];
        for(var i = 0 ; i < s.length ; i ++){
            if(s[i].length > 0){
                var mx = [];
                var ss = s[i].split(',');
                for(var j = 0 ; j < ss.length ; j ++){
                    if(ss[j].length > 0){
                        mx.push(ss[j]);
                    }
                }
                total.push(mx);
            }
        }
        data.push(total);

        Ext.define('Employee', {
            extend: 'Ext.data.Model',
            fields: [
                { name: 'x', type: 'float' },
                { name: 'y', type: 'float' },
                { name: 'h', type: 'float' },
                { name: 'n', type: 'float' }
            ]
        });

        var store = Ext.create('Ext.data.Store', {
            model: 'Employee',
            data:data
        });

        var grid = Ext.create('Ext.grid.Panel',{
            autoHeight:true,
            store:store,
            columns:[
                {header:'长',dataIndex:'x'},
                {header:'宽',dataIndex:'y'},
                {header:'高',dataIndex:'h'},
                {header:'数量',dataIndex:'n'}
            ]
        });

        var window = Ext.create('Ext.window.Window', {
            title: '货物尺寸',
            layout:'fit',
            closeAction:'hide',
            resizable:false,
            height:350,
            autoScroll:true,
            width:400,
            plain: true,
            modal:true,
            draggable:true,
            items:grid,
            buttons:[{
                text:'关闭',
                handler:function(){
                    window.hide();
                }
            }]
        });


        var form = Ext.create('Ext.form.Panel',{
            frame:true,
            title:'委托单明细',
            height:'100%',
            width:'100%',
            autoScroll:true,
            fieldDefaults: {
                labelAlign:'right',
                labelWidth: 80,
                width:350,
                readOnly:true
            },
            items:[{
                xtype:'fieldset',
                title:"基础信息",
                autoWidth:true,
                autoHeight:true,
                layout:{
                    type: 'table',
                    columns: 2
                },
                defaultType: 'textfield',
                items:[{
                    fieldLabel:'工作内容',
                    value:result.contentName
                },{
                    fieldLabel:'委托方',
                    value:result.customerName
                }]
            },{
                xtype:'fieldset',
                title:"详细信息",
                autoWidth:true,
                autoHeight:true,
                layout:{
                    type: 'table',
                    columns: 2
                },
                defaultType: 'textfield',

                items:[{
                    fieldLabel:'起始港',
                    value:result.startAirportName
                },{
                    fieldLabel:'目的港',
                    value:result.endAirportName
                },{
                    fieldLabel:'货品名称',
                    value:result.cargoName,
                    colspan:2
                },{
                    fieldLabel:'数量',
                    value:result.num+result.unitName
                },{
                    xtype: 'fieldcontainer',
                    fieldLabel: '尺寸描述',
                    combineErrors: true,
                    layout: 'hbox',
                    items:[{
                        xtype:'textfield',
                        readOnly:true,
                        value:result.sizeDesc,
                        width:205
                    },{
                        xtype:'button',
                        text:'查看尺寸',
                        handler:function(b,e){
                            window.show(b);
                        }
                    }]
                },{
                    fieldLabel:'体积',
                    value:result.volume
                },{
                    fieldLabel:'重量',
                    value:result.weight
                },{
                    fieldLabel:'希望的航班',
                    value:result.flight
                },{
                    fieldLabel:'航班日期',
                    value:result.flightDateStr
                },{
                    fieldLabel:'入库方式',
                    value:result.depotInName
                },{
                    fieldLabel:'入库预计时间',
                    value:result.depotInDesc
                },{
                    fieldLabel:'报关方式',
                    value:result.flagName
                },{
                    fieldLabel:'报关日期',
                    value:result.bgDateStr
                },{
                    fieldLabel:'<font color="red">所报运价</font>',
                    value:result.price
                },{
                    fieldLabel:'制单人',
                    value:result.creatorName
                },{
                    xtype:'textarea',
                    fieldLabel:'备注信息',
                    width:700,
                    value:result.remark,
                    colspan:2
                }]
            }],
            renderTo:Ext.getBody(),
            buttonAlign:'center',
            buttons:[{
                text:'关闭',
                handler:function(){
                    self.close();
                }
            }]
        });

    });
})();
</script>
</head>
<body>
</body>
</html>